import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/models/chat_message_model.dart';
import 'package:flutter_chat_ui/utils/utils.dart';
import 'package:flutter_chat_ui/views/chat_message.dart';

import 'package:lottie/lottie.dart';

class ChatElementOther extends StatefulWidget {
  /// 消息
  final ChatMessageData chatMessage;

  const ChatElementOther({
    super.key,
    required this.chatMessage,
  });

  @override
  State<ChatElementOther> createState() => _ChatElementOtherState();
}

class _ChatElementOtherState extends State<ChatElementOther> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.only(top: 24),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          /// 头像
          Padding(
            padding: const EdgeInsets.only(left: 18),
            child: GestureDetector(
              onTap: () {},
              child: Image.asset(
                'assets/icon_robot_avatar.png',
                width: 30,
                height: 30,
              ),
            ),
          ),

          /// 内容
          Expanded(
            child: widget.chatMessage.isRobotLoading == true
                ? Row(
                    children: [
                      Lottie.asset(
                        'assets/json/sound_wave.json',
                        width: 50,
                        height: 25,
                      )
                    ],
                  )
                : ChatMessageWidget(
                    eventType: MessageEventType.robot,
                    content: widget.chatMessage.robotResponseText,
                    suggestedQuestions: widget.chatMessage.suggestedQuestions,
                  ),
          ),
        ],
      ),
    );
  }
}
